#pragma once

#include "Infra/Vector.h"
#include "Infra/Function.h"
#include "GenICam/System.h"
#include "IPCfg.h"

// CDeviceList 对话框
// CDeviceList dialog

class CDeviceList : public CDialog
{
	DECLARE_DYNAMIC(CDeviceList)

public:
	CDeviceList(CWnd* pParent = NULL);   // 标准构造函数 | construct function
	virtual ~CDeviceList();
	
	// 连接通知回调 | connect notification callback function
	typedef Dahua::Infra::TFunction2<void, Dahua::GenICam::ICameraPtr, bool> Proc;
	
	// 初始化对象 |initial object
	void initDlg(Proc const& callBack);

	// 对话框数据 | dialog data
	enum { IDD = IDD_DEVICELIST };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持 | DDX/DDV support

	DECLARE_MESSAGE_MAP()

private:
	
	typedef Dahua::Infra::TVector<Dahua::GenICam::ICameraPtr> CameraVec;
	
	// initilize tree view
	void initTree(CameraVec& cameraPtrVec);

	void onSetIpOK();
	
	Dahua::GenICam::CSystem&    _systemIns;
	CameraVec                   _cameraVec;
	Dahua::GenICam::ICameraPtr  _currentCamera;
	HTREEITEM                   _selectItem;
	IPCfg*                      _ipCfgDlg;
	Proc                        _callBackFunc;

public:
	
	afx_msg void OnNMRclickTreeDevlist(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnMenuConnect();
	afx_msg void OnMenuModify();
};
